package main

import (
	"flag"
	"fmt"
	"google.golang.org/grpc"
	"google.golang.org/grpc/reflection"
	"graduation/database"
	"graduation/design"
	"graduation/service"
	"net"
)

var bind = flag.String("bind","127.0.0.1:8000","启动地址")

func init(){
	database.InitDataBase()
}
func main() {
	flag.Parse()
	fmt.Println(*bind)
	lis, lisError := net.Listen("tcp", *bind)
	if lisError != nil{
		fmt.Println("套接字端口被占用")
		return
	}
	grpcServer := grpc.NewServer()
	design.RegisterGraduationDesignServer(grpcServer, &service.LoginService{})
	design.RegisterGraduationDesignAdminCoreServer(grpcServer,&service.RoleService{})
	design.RegisterAdminActionsServer(grpcServer, &service.AdminService{})
	design.RegisterPermissionServiceServer(grpcServer,&service.PermissionService{})
	reflection.Register(grpcServer)
	error := grpcServer.Serve(lis)
	if error != nil {
		fmt.Println(error)
	}
}
